package com.andy.service.impl;

import com.andy.dao.entity.Article;
import com.andy.dao.repository.AriticleRepository;
import com.andy.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private AriticleRepository ariticleRepository;

    @Value("${page.size}")
    private Integer pageSize;

    @Override
    public Page<Article> getArticles(int pageStart) {
        Pageable page = PageRequest.of(pageStart, pageSize);
        return ariticleRepository.findAll(page);
    }
}
